package com.zy.dom4j.example;

import org.dom4j.Document;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.XMLWriter;

import java.io.FileWriter;
import java.io.IOException;

/**
 * Created by Allen on 2017/3/13.
 */
public class DocumentWrite {

    public void write(Document document) throws IOException {

        System.out.println(this.getClass().getResource("/"));

        // lets write to a file
        XMLWriter writer = new XMLWriter(
                new FileWriter(  "output.xml" )

        );
        writer.write( document );
        writer.close();


//        // Pretty print the document to System.out
//        OutputFormat format = OutputFormat.createPrettyPrint();
//        writer = new XMLWriter( System.out, format );
//        writer.write( document );
//
//        // Compact format to System.out
//        format = OutputFormat.createCompactFormat();
//        writer = new XMLWriter( System.out, format );
//        writer.write( document );
    }

}
